package com.uraurora.crescent.function;

import java.util.Objects;

@FunctionalInterface
public interface Action5<T1,T2, T3, T4, T5> {

    void on(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);

    default Action5<T1, T2, T3, T4, T5> before(Action5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5> before) {
        Objects.requireNonNull(before);
        return (T1 t1,T2 t2, T3 t3, T4 t4, T5 t5) -> { before.on(t1, t2, t3, t4, t5); on(t1, t2, t3, t4, t5); };
    }

    default Action5<T1, T2, T3, T4, T5> after(Action5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5> after) {
        Objects.requireNonNull(after);
        return (T1 t1,T2 t2, T3 t3, T4 t4, T5 t5) -> { on(t1, t2, t3, t4, t5); after.on(t1, t2, t3, t4, t5); };
    }

    //<editor-fold desc="柯里化与反柯里化">
    default Action4<T2, T3, T4, T5> curry1(T1 t1){
        return (t2, t3, t4, t5) -> on(t1, t2, t3, t4, t5);
    }

    default Action4<T1, T3, T4, T5> curry2(T2 t2){
        return (t1, t3, t4, t5) -> on(t1, t2, t3, t4, t5);
    }

    default Action4<T1, T2, T4, T5> curry3(T3 t3){
        return (t1, t2, t4, t5) -> on(t1, t2, t3, t4, t5);
    }

    default Action4<T1, T2, T3, T5> curry4(T4 t4){
        return (t1, t2, t3, t5) -> on(t1, t2, t3, t4, t5);
    }

    default Action4<T1, T2, T3, T4> curry5(T5 t5){
        return (t1, t2, t3, t4) -> on(t1, t2, t3, t4, t5);
    }

    default Action3<T3, T4, T5> curry(T1 t1, T2 t2){
        return (t3, t4, t5) -> on(t1, t2, t3, t4, t5);
    }

    default Action2<T4, T5> curry(T1 t1, T2 t2, T3 t3){
        return (t4, t5)->on(t1, t2, t3, t4, t5);
    }

    default Action1<T5> curry(T1 t1, T2 t2, T3 t3, T4 t4){
        return t5 -> on(t1, t2, t3, t4, t5);
    }
    //</editor-fold>
}